﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StortListDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            SortedList sortlist = new SortedList();
            sortlist.Add(1, "沉沉");
            sortlist.Add(2, "辰辰");
            sortlist.Add(3, "晨晨");
            sortlist.Add(4, "陈陈");
            sortlist.Add(5, "宸宸");
            sortlist.Add(6, "琛琛");
            sortlist.Add(7, "尘尘");
            sortlist.Add(8, "抻抻");
            

            Console.WriteLine("以下：");
            foreach (DictionaryEntry dec in sortlist)
            {
                int key = (int)dec.Key;
                string name = dec.Value.ToString();
                Console.WriteLine("排序：{0}名字：{1}",key,name);
            }
            Console.WriteLine();
            Console.WriteLine();


            Console.WriteLine("请输入序号：");
            int ls = int.Parse(Console.ReadLine());
            var cd = sortlist.ContainsKey(ls);
            if(cd)
            {
                string name = sortlist[ls].ToString();
                Console.WriteLine("查找的人为：{0}",name);
            }
            else
            {
                Console.WriteLine("对不起！没有此人");
            }
        }
    }
}
